package map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by SliverZhang on 2017/11/20.
 */
public class TestMap {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("一",1);
        map.put("二",2);
        map.put("三",3);
        map.put(null,8);
        System.out.println(map.get("一"));
        System.out.println(map.get("六"));
        System.out.println(map.get(null));

        //输出
        Set<String> keyset = map.keySet();
        Iterator iterator = keyset.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        Set<Map.Entry<String,Integer>> set = map.entrySet();
        Iterator<Map.Entry<String,Integer>> itr = set.iterator();
        while (itr.hasNext()){
            Map.Entry<String,Integer> me = itr.next();
            System.out.println(me.getKey()+"="+me.getValue());
        }
    }
}
